//
//  UILabel+Yyx.m
//  didacar
//
//  Created by 度周末网络-王腾 on 15/12/2.
//  Copyright © 2015年 dzmmac. All rights reserved.
//

#import "UILabel+Yyx.h"
#import "AppColorConfig.h"
@implementation UILabel (Yyx)

-(void)addUnderLine{
    NSMutableAttributedString *content = [[NSMutableAttributedString alloc] initWithString:self.text];
    NSRange contentRange = {0, [content length]};
    [content addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:contentRange];
    [content addAttribute:NSStrikethroughColorAttributeName value:self.textColor range:NSMakeRange(0, [self.text length])];
    [self setAttributedText:content];
}

-(void)setDeleteLine{
    NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithString:self.text];
    [attri addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlineStyleSingle) range:NSMakeRange(0, [self.text length])];
    [attri addAttribute:NSStrikethroughColorAttributeName value:self.textColor range:NSMakeRange(0, [self.text length])];
    [self setAttributedText:attri];
}

-(void)setDeleteLine:(NSString *)lineString{
    NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithString:lineString];
    
    NSRange range = [lineString rangeOfString:self.text];
    [attri addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlineStyleSingle) range:range];
    [attri addAttribute:NSStrikethroughColorAttributeName value:self.textColor range:range];
    [self setAttributedText:attri];
}

-(void)statusHidden{
    self.hidden = YES;
}

// 已经报名
-(void)statusRegistration{
    self.text = @"已报名";
    self.textColor = [UIColor whiteColor];
    self.backgroundColor = GLOBLE_GRAY_COLOR_2;
    self.layer.cornerRadius = 2;
    self.layer.masksToBounds= YES;
}

// 待报名
-(void)statusWaitRegistration{
    self.text = @"待报名";
    self.textColor = [UIColor whiteColor];
    self.backgroundColor = GLOBLE_ORANGE_COLOR;
    self.layer.cornerRadius = 2;
    self.layer.masksToBounds= YES;
}

//- (void)drawRect:(CGRect)rect
//{
//    [super drawRect:rect];
//    CGContextRef ctx = UIGraphicsGetCurrentContext();
//    CGSize fontSize =[self.text sizeWithFont:self.font
//                                    forWidth:self.frame.size.width
//                               lineBreakMode:NSLineBreakByTruncatingTail];
//    
//    CGContextSetStrokeColorWithColor(ctx, self.textColor.CGColor);
//    CGContextSetLineWidth(ctx, 0.45f);
//    
//    CGPoint leftPoint = CGPointMake(0,
//                                    self.frame.size.height);
//    CGPoint rightPoint = CGPointMake(self.frame.size.width,
//                                     self.frame.size.height);
//    CGContextMoveToPoint(ctx, leftPoint.x, leftPoint.y);
//    CGContextAddLineToPoint(ctx, rightPoint.x, rightPoint.y);
//    CGContextStrokePath(ctx);
//}
@end
